// Safe Delete Macros. Ensures a pointer exists and is valid before calling delete/delete[].
#define SAFE_DELETE( p )       { if( p ) { delete ( p );     ( p ) = NULL; } }
#define SAFE_DELETE_ARRAY( p ) { if( p ) { delete[] ( p );   ( p ) = NULL; } }

// Safe Release Macro. Used for DirectX/Win32.
#define SAFE_RELEASE( p )      { if( p ) { ( p )->Release(); ( p ) = NULL; } }